package com.colin.aiyi.entity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.support.annotation.NonNull;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by hl on 2017/5/23.
 */

public class Song {




    private String mTitle;

    private String mArtist;

    private String mLrcPath;

    private String mSongPath;

    private int mDuration;

    private Bitmap mCover;

    private Bitmap mCoverMirror;

    private Bitmap mCoverGauss;

    public String getmSongPath() {
        return mSongPath;
    }







    public void setDuration() {
        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        mmr.setDataSource(mSongPath);
        mDuration = Integer.valueOf(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
    }

    public int getDuration() {
        if (mDuration == 0) {
            setDuration();
        }
        return mDuration;
    }

    public String getFormatDuration() {
        long time = getDuration();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date(time));
        double minute = calendar.get(Calendar.MINUTE);
        double second = calendar.get(Calendar.SECOND);

        DecimalFormat format = new DecimalFormat("00");
        return format.format(minute) + ":" + format.format(second);
    }




    public void setCoverMirror() {
    }

    public void setCoverGauss() {
    }

}
